﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Genealogy_Builder
{
    public partial class PlaceDialog : Form
    {
        public Place newPlace;
        bool pass = true;

        public PlaceDialog()
        {
            InitializeComponent();
            txtPID.Text = Place.ID.ToString();

        }

        public bool AddPlace()
        {
            this.ShowDialog();
            return pass;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtCountry.Text == "" || txtCity.Text == "" || txtZip.Text == "")
            {
                MessageBox.Show("Country, City, and Zip must have values.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                newPlace = new Place(txtZip.Text, txtCity.Text, txtState.Text, txtCountry.Text);
                this.Close();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            pass = false;
            this.Close();
        }
    }
}
